package stegosaur.cli;

import java.io.File;
import stegosaur.volume.*;

/**
 * <p>
 * A quick and dirty helper class to parse command line arguments.
 * </p>
 *
 * @author gndn.k5
 * @since Stegosaur 1.0
 */
final class Options
{
  public boolean showHelp;
  public boolean createVolume;
  public String passphrase;
  public VolumeParameters volumeParameters;
  
  Options(String[] args) throws Exception
  {
    volumeParameters = new VolumeParameters();
    
    for (String s : args)
    {
      if (s.equals("-h") || s.equals("--help"))
        showHelp = true;
        
      else if (s.equals("-c") || s.equals("--create"))
        createVolume = true;
        
      else if (s.startsWith("--masterFile="))
        volumeParameters.masterFile = new File(s.substring(13));
        
      else if (s.startsWith("--volumeName="))
        volumeParameters.name = s.substring(13);
       
      else if (s.startsWith("--splitSize="))
        volumeParameters.splitFileSizeMB = Integer.parseInt(s.substring(12));
        
      else if (s.startsWith("--splitNameFormat="))
        volumeParameters.splitFileNameFormat = s.substring(18);
        
      else if (s.startsWith("--blockSize="))
        volumeParameters.blockSize = Integer.parseInt(s.substring(12));
        
      else if (s.startsWith("--capacity="))
        volumeParameters.capacityMB = Integer.parseInt(s.substring(11));
        
      else if (s.startsWith("--pass="))
        passphrase = s.substring(7);
    }
  }
}
